import { TextField } from '@mui/material'
import PropsType from "prop-types";

// 如果外部有onChange的情况下，用外部的onChange，并且外部一定要用setFieldValue赋值给输入框
const MyTextField = ({placeholder, label, field, type, InputProps, onChange}) => {
  return (
    <TextField {...field} onChange={onChange ? onChange : field.onChange} placeholder={placeholder} label={label} variant="filled" type={type} InputProps={InputProps}/>
  )
}

MyTextField.propTypes = {
  placeholder: PropsType.string,
  label: PropsType.string.isRequired,
  field: PropsType.object.isRequired,
  type: PropsType.string,
  onChange: PropsType.func
}

MyTextField.defaultProps = {
  placeholder: '请输入',
  type: 'text'
}

export default MyTextField